package com.rpc.framework;


import com.rpc.framework.cdec.Encoder;

import javax.xml.ws.Response;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * Description:
 * User: 27010
 * DateTime: 2017/8/21 22:15
 */
public class RpcClient implements Encoder {
    private String host;
    private int port;
    private Socket socket;

    public RpcClient(String host, int port) throws IOException {
        this.host = host;
        this.port = port;
        this.socket = new Socket(host, port);
    }

    public Response send(Request request) throws IOException {
        byte[] sendData = encode(request);
        OutputStream out = socket.getOutputStream();
        out.write(sendData);
        out.flush();

        InputStream in  = socket.getInputStream();
        return null;
    }

    @Override
    public <T> byte[] encode(T obj) {
        return null;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }
}
